package com.heima.article.controller.v1;

import com.heima.apis.comment.ICommentClient;
import com.heima.article.service.CommentByService;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.mongo.comment.dtos.CommentDto;
import com.heima.mongo.comment.dtos.CommentLikeDto;
import com.heima.mongo.comment.dtos.CommentSaveDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment")
public class CommentController implements ICommentClient {
    @Autowired
    private CommentByService commentByService;

    @Override
    @PostMapping("/save")
    public ResponseResult getSave(@RequestBody CommentSaveDto dto) {
        return commentByService.getSave(dto);
    }

    @Override
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDto dto) {
        return commentByService.like(dto);
    }

    @Override
    @PostMapping("load")
    public ResponseResult load(@RequestBody CommentDto dto) {
        return commentByService.load(dto);
    }
}
